//
//  ImageButton.m
//  GIFShow
//
//  Created by lanou11air029 on 15/4/24.
//  Copyright (c) 2015年 CK. All rights reserved.
//

#import "ImageButton.h"

@implementation ImageButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
+(instancetype)buttonWithType:(UIButtonType)buttonType{
    ImageButton * button  = [super buttonWithType:buttonType];
    if(button){
        button.imageView.contentMode = UIViewContentModeScaleAspectFill;
        button.titleLabel.textAlignment = NSTextAlignmentCenter;
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleShadowColor:[UIColor yellowColor] forState:UIControlStateNormal];
//        button.backgroundColor = [UIColor colorWithWhite:1 alpha:0.8];
//        button.titleLabel.textColor = [UIColor blackColor];
    }
    return button;
}
-(void)setImage:(UIImage *)image forState:(UIControlState)state{
    UIImage * imageShow = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [super setImage:imageShow forState:state];
    
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect{
    return CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect{
    return CGRectMake(0, self.frame.size.height*0.8, self.frame.size.width, self.frame.size.height*0.2);
}



@end
